<%--
 *  File:   DoctorInfoReport1.jsp
 *  Desc:	Report Director depend on eSpreadsheet
 *
 *  Date		         Author		      Changes
 *  2013-01-23	  		 shigang	 	  Created
 *   
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%//init param
			String privilegeCode = "11930";
			//String strTableName = "";
			String strModuleName = "COM";
			String contextPath = request.getContextPath();

			%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%@ include file="/rpt/ReportURL.inc"%>
<iframe name="reloadHandler" style="display:none"></iframe>
<html>
<head>
<title>Regionalcoveragereports</title>
<PageFlow:CheckPageFlow pageName="p_employeeinfo" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>


<%@ include file="/inc/SummaryDivision.inc" %>
<%Vector totalsummary = (Vector) pageContext.getAttribute("totalsummary");
			if (totalsummary == null)
				totalsummary = new Vector();		

			HashMap deptinfo = (HashMap) session.getAttribute("deptinfo");
			if (deptinfo == null)
				deptinfo = new HashMap();
			
			HashMap UserInfo = (HashMap) session.getAttribute("userinfo");
			if (UserInfo == null)
				UserInfo = new HashMap();
    Integer loginemployeeid = (Integer)UserInfo.get("employeeid");
    
    java.util.Calendar cal = java.util.Calendar.getInstance(); 
    String flag = (String)pageContext.getAttribute("flag");
    
    HashMap orgInfo = (HashMap)pageContext.getAttribute("orginfo");

    if(orgInfo == null)
      orgInfo = new HashMap();
    
    Integer ishead = (Integer)orgInfo.get("ischain");
    if(ishead==null)
  	  ishead = new Integer(-1);
			%>

<%--  put your custom script here   --%>

<script language="JavaScript">

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  	editform.action = "Regionalcoveragereports.jsp?<%= OvalTools.randomURL() %>";
    editform.target = "_self";
    isRunning = true;
    editform.submit();
}



function downloadcsv() {
	var begindate = document.cform.beginyear.value+"-"+document.cform.beginmonth.value;
	//var beginmonth = document.cform.beginmonth.value;
	var enddate = document.cform.endyear.value+"-"+document.cform.endmonth.value;
	//var endmonth = document.cform.endmonth.value;
	var prodid = document.cform.prodid.value;
	var orgid = document.cform.orgid.value;
	var partnerid = document.cform.partnerid.value;
	var areaid = document.cform.areaid.value;
	var salestype = document.cform.salestype.value;
	var regionareaid = document.cform.regionareaid.value;
	var salesdetailtype = document.cform.salesdetailtype.value;

    var viewflowdatetype = document.cform.viewflowdatetype.value;


    if (salesdetailtype == 1)
	{     if (viewflowdatetype == 1)
	        {       
                   var url1 = "<%=reportURL%>/csv?__report=/ovalreport/salesdetail.txt"+"&salesbegindate="+begindate  +"&salesenddate="+enddate+"&loginenddate="+enddate +"&itemidstr=" +prodid +"&prodids=" +prodid +"&orgidstr="+orgid+"&partneridstr="+partnerid+"&areaidstr="+areaid+"&salestype="+salestype+"&partnerareaidstr="+regionareaid+"&loginuserid=<%=loginemployeeid%>&zip=true";
    
                      var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
                       popwindow = window.open(url1, "n1window", strstatus);
                        
                        
                                    }else
            {
                var url1 = "<%=reportURL%>/csv?__report=/ovalreport/salesdetail.txt"+"&begindate="+begindate  +"&enddate="+enddate +"&loginenddate="+enddate +"&itemidstr=" +prodid +"&prodids=" +prodid +"&orgidstr="+orgid+"&partneridstr="+partnerid+"&areaidstr="+areaid+"&salestype="+salestype+"&partnerareaidstr="+regionareaid+"&loginuserid=<%=loginemployeeid%>&zip=true";
                        var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
                        popwindow = window.open(url1, "n1window", strstatus);
            }
    }else{
	if (salesdetailtype == 2)
	{
        if (viewflowdatetype == 1)
	        {
                 var url1 = "<%=reportURL%>/csv?__report=/ovalreport/Purchasedetail.txt"+"&salesbegindate="+begindate  +"&salesenddate="+enddate +"&loginenddate="+enddate +"&itemidstr=" +prodid +"&prodids=" +prodid +"&orgidstr="+orgid+"&partneridstr="+partnerid+"&areaidstr="+areaid+"&salestype="+salestype+"&partnerareaidstr="+regionareaid+"&loginuserid=<%=loginemployeeid%>&zip=true";
                var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
                popwindow = window.open(url1, "n1window", strstatus);
            }else
            {
                var url1 = "<%=reportURL%>/csv?__report=/ovalreport/Purchasedetail.txt"+"&begindate="+begindate  +"&enddate="+enddate+"&loginenddate="+enddate  +"&itemidstr=" +prodid +"&prodids=" +prodid +"&orgidstr="+orgid+"&partneridstr="+partnerid+"&areaidstr="+areaid+"&salestype="+salestype+"&partnerareaidstr="+regionareaid+"&loginuserid=<%=loginemployeeid%>&zip=true";
                    var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
                    popwindow = window.open(url1, "n1window", strstatus);
            }

	}
	else
	{
        if (viewflowdatetype == 1)
	        {
                 var url1 = "<%=reportURL%>/csv?__report=/ovalreport/Alldetail.txt"+"&salesbegindate="+begindate  +"&salesenddate="+enddate +"&loginenddate="+enddate +"&itemidstr=" +prodid +"&prodids=" +prodid +"&orgidstr="+orgid+"&partneridstr="+partnerid+"&areaidstr="+areaid+"&salestype="+salestype+"&partnerareaidstr="+regionareaid+"&loginuserid=<%=loginemployeeid%>&zip=true";
                    var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
                    popwindow = window.open(url1, "n1window", strstatus);
            }else
            {
               var url1 = "<%=reportURL%>/csv?__report=/ovalreport/Alldetail.txt"+"&begindate="+begindate  +"&enddate="+enddate +"&loginenddate="+enddate +"&itemidstr=" +prodid +"&prodids=" +prodid +"&orgidstr="+orgid+"&partneridstr="+partnerid+"&areaidstr="+areaid+"&salestype="+salestype+"&partnerareaidstr="+regionareaid+"&loginuserid=<%=loginemployeeid%>&zip=true";
                var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
                popwindow = window.open(url1, "n1window", strstatus);
            }

	}
    }
}

function page_popBusinessarea()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/ogm/zylstdbusinessareapop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function page_popProductbrand()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/upm/ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function popCountyArea()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/map/CountyAreaAllWindow.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function setCountyArea(userid,countyareaname,countyareaid,countyareacode)
{
	document.cform.countyareaname.value=countyareaname;
	document.cform.countyareacode.value=countyareacode;
}
function popRep() {
	

	var regionid=document.cform.regionareaid.value;
	//var proviceofficecode = document.cform.proviceofficelist.value;
	//var businessareacode = document.cform.businessarealist.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid;
  
	popwindow = window.open(url, "newwindow", status);
  }

function SetSalesMan(id,code,name){
	cform.employeeid.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

function setContact(id,type,name){

	document.cform.regionareaid.value=id;
	document.cform.regionname.value=name;
}

function set_orgNameByPopWindow(productgroupid,productgroupcode,productgroupname){

	document.cform.productbrandid.value=productgroupid;
	document.cform.productbrandname.value=productgroupname;
}
var popwindow;

function page_setRegion(code,name)
{
  if(code != document.cform.regioncode.value)
  {
    //document.cform.citycode.value = " ";
    //document.cform.cityname.value = " ";
    //document.cform.countycode.value = " ";
    //document.cform.countyname.value = " ";
  }
  document.cform.regioncode.value= code;
  document.cform.regionname.value = name;
  if (popwindow != null)
    popwindow.close();
}

function page_selectProvince()
{
  if(popwindow!=null)
    popwindow.close();
  popwindow = window.open('<%=contextPath %>/masterdata/ogm/zylstdbusinessareapop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}

function page_selectDept(){
	if(popwindow!=null)
	    popwindow.close();
	  popwindow = window.open('<%=contextPath %>/phap/masterdata/erm/StandardDeptSummaryForPop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}

function setDept(value,name){
	document.cform.standardsectionid.value=value;
	document.cform.deptname.value=name;
	
}
function setRealityDept(code,name){
	document.cform.realitydeptcode.value=code;
	document.cform.realitydeptname.value=name;
	
}
function page_HospitalSummaryForPop(){
	if(popwindow!=null)
	    popwindow.close();
	  popwindow = window.open('<%=contextPath %>/phap/masterdata/erm/zylRealityDeptSummaryForPop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}


function popRep() {

	var regioncode=document.cform.regioncode.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/masterdata/ogm/RegionSelect.jsp?<%= OvalTools.randomURL() %>&regioncode="+regioncode;
	
	popwindow = window.open(url, "newwindow", status);
  }


function page_popwindow1(){
  	if(popwindow!=null)
    	popwindow.close();
  		var strurl="<%=contextPath%>/phap/phap.datp/masterdata/kdm/ProductSelect.jsp?<%= OvalTools.randomURL()%>&languagecode=<%=strLanguageCode%>&clear=Y&category=4";
  	   var strStatus= "height=700,width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=yes";
 	   popwindow=window.open(strurl, "newwindow",strStatus);
}

function page_setproduct(id,umcode,prodcode,prodname){
	
	document.cform.prdn.value=prodname;
	document.cform.prodid.value=id;

}

function exportCenterPeople(Year,Months){
	

	//cform.deptid.options[0].selected=true;
	/**
	deptid 		   	部门Id
	regionareaid 	省区Id
	areatype     	业务区域类型
	productbrandid  产品组
	countyareacode  县域code
	employeeid     员工id
	
	*/
	var date = Year+"-"+Months;
	var deptid = document.cform.deptids.value;
	var regionareaid = document.cform.regionareaid.value;
	//var areatype = document.cform.areatype.value;
	var productbrandid = document.cform.productbrandid.value;
	var employeeid=document.cform.employeeid.value;
	//var countyareacode=document.cform.countyareacode.value;
	var standardsectionid=document.cform.standardsectionid.value;
	var realitydeptcode=document.cform.realitydeptcode.value;
	var status = document.cform.status.value;
	if(""==Year&&""==Months){

	    if(deptid ==-1) {
		    alert("<%= message.getMessageDesc("L_DEPT_NOT_NULL")%>");
		    }
	    else{
		//if( !document.cform.deptids.options[0].selected || !document.cform.areatype.options[0].selected)
		    var url = "<%=reportURL%>/servlet/ExcecuteReport/DoctorInfoReport1B.sox?__format=xlsx&__folder=/ovalreport&deptid="+deptid+"&date="+date+"&regionareaid="+regionareaid+"&productbrandid="+productbrandid+"&employeeid="+employeeid+"&standardsectionid="+standardsectionid+"&realitydeptcode="+realitydeptcode+"&status="+status;
		    var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
		   
		    popwindow = window.open(url, "n1window", strstatus);
	    	}
		}
		else if(""==Year && "" != Months){
		alert("<%= message.getMessageDesc("YEARDATE_NOT_NULL")%>");
		}
		else if(""!=Year && ""==Months){
		alert("<%= message.getMessageDesc("MONTHSDATE_NOT_NULL")%>");
		}
		else{
		    if(deptid ==-1) {alert("<%= message.getMessageDesc("L_DEPT_NOT_NULL")%>");}
		    else{
			//if( !document.cform.deptids.options[0].selected || !document.cform.areatype.options[0].selected)
			    var url = "<%=reportURL%>/servlet/ExcecuteReport/DoctorInfoReport1.sox?__format=xlsx&__folder=/ovalreport&deptid="+deptid+"&date="+date+"&regionareaid="+regionareaid+"&productbrandid="+productbrandid+"&employeeid="+employeeid+"&standardsectionid="+standardsectionid+"&realitydeptcode="+realitydeptcode+"&status="+status;
			    var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
			   
			    popwindow = window.open(url, "n1window", strstatus);
			    }
			}


}

function exportAreaPeople(startdate,enddate){


	if(isEmpty(document.cform.startdate.value) || isEmpty(document.cform.enddate.value)){
		  
		  alert("<%= message.getMessageDesc("TimePeriod_NOT_NULL",label.getLabelName("L_TimePeriod"))%>");
		    return;
		  }	
	//var deptid = document.cform.deptids.value;
	var regionname = document.cform.regionname.value;
	var orgname=document.cform.orgname.value;
	var prodid=document.cform.prodid.value;



    var url = "<%=reportURL%>/servlet/ExcecuteReport/ExportProdCollateReport.sox?__format=xlsx&__folder=/ovalreport&regionname="+escape(encodeURI(regionname))+"&orgname="+escape(encodeURI(orgname))+"&prodid="+prodid+"&startdate="+startdate+"&enddate="+enddate;
    var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
    	   
   popwindow = window.open(url, "n1window", strstatus);


}


</script>

</head>
<body style="overflow: auto;" >
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
	<input type="hidden" name="pagename" value="p_employeeinfo">
	<input type="hidden" name="actionname">
	<input type="hidden" name="prodcode">
    <input type="hidden" name="flag"/>
	<custom:hidden property="languagecode" scope="session" name="userinfo"/>
	<custom:hidden property="contactid" scope="session" name="userinfo" changedName="loginid"/>
	<%--  page location   --%>
<%@ include file="/inc/PageLocation.inc"%>

<%@ include file ="/inc/NewCalendar.inc" %>
<table width="100%" border="0" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
<!-------------------------------------1 row -------------------------------------------------->
	 <tr>
	<%
         			Integer statusO = (Integer)pageContext.getAttribute("status");
         			if(statusO == null) statusO = new Integer(0);
         			int status = statusO.intValue();
         			String startdate = (String)pageContext.getAttribute("startdate");
         			if(startdate == null) startdate = "";
         			String enddate = (String)pageContext.getAttribute("enddate");
         			if(enddate == null) enddate = "";
         		%>
				
	
		<!-- <td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Department")+ label.getLabelName("L_Colon")%>
			</div>
		</td>
		<td>
			       <custom:select property="deptids" optionsName="alldeptnames"
							optionValueKey="deptid" optionInnerTextKey="deptname" defaultValue="--------"/>
	   </td>
	    -->
	   <td class="text-align:left"><%=label.getLabelName("L_Province") +  label.getLabelName("L_Colon") %>
				
					<custom:text property="regionname" 
					size="20" readonly="false" style="border:1px #7F9DB9 solid;" /> <a
					onClick="javascript:popRep();"><custom:button type="3"
					label="L_Asterisk" imgsrc="flash.gif" border="0" /></a><custom:hidden property="regioncode" />
	 </td>
	 
	 <td class="text-align:left"><%=label.getLabelName("L_DealerName") +  label.getLabelName("L_Colon") %>
				
					<custom:text property="orgname" size="20" readonly="false" style="border:1px #7F9DB9 solid;" /> 

	 </td>
	   <td class="need"><%= label.getLabelName("L_TimePeriod") + label.getLabelName("L_Colon") %></td>
	   <td>
	      <input type="text" name="startdate" value="<%=JspHelper.filterNull( startdate )%>" onblur="if(startdate.value<0){alert('<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_BeginningDate",false)) %>');startdate.focus();}">
	      <a onclick="javascript:c.show(this,'cform.startdate','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>')"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>--
	     <input type="text" name="enddate" value="<%=JspHelper.filterNull( enddate )%>" onblur="if(enddate.value<0){alert('<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_EndingDate",false)) %>');enddate.focus();}">
	     <a onclick="javascript:c.show(this,'cform.enddate','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>')"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>&nbsp;
	 </td>
	 
	 <td class="title_center">
			<div align="left">
				<%=label.getLabelName("L_Product")	+ label.getLabelName("L_Colon")%>
				<custom:text  property="prdn" size="30" readonly="true"/>&nbsp;<a onclick="page_popwindow1();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
        		<custom:hidden property="prodid"/>
        		
		  </div>
          </td>
	</tr>

 </table>

		 <table width="100%" cellspacing="0" cellpadding="0">
		        <tr>
		          <td class="summary_top"></td>
		        </tr>
		        
		        <tr>
		          	<td class="td_center">
			  		
				  		
				  		<a onclick="javascript:exportAreaPeople(document.cform.startdate.value,document.cform.enddate.value);"><custom:button type="1" label="L_Execcd" imgsrc="CreatSubDept.gif" border="0"  /></a>
				  		<!-- <a onclick="javascript:exportCenterPeople(document.cform.startyears.value,document.cform.startmonths.value);"><custom:button type="1" label="L_CenterPeople" imgsrc="CreatSubDept.gif" border="0" privilegeCode="BB1022902"/></a> -->

					</td>
		        </tr>
     	</table>
</form>
</body>
</html>
